#include <head.h>

int main(int argc,char const *argv[])
{
    int fd_set = open(argv[1],O_RDWR | O_CREAT | O_APPEND,0666);
    FOPEN_ERR(fd_set);
    lseek(fd_set,0,SEEK_SET);
    int fd_src = -1;
    int bytes = 0;
    char buf[1024];

    if(3 > argc)
    {
        printf("格式错误 : %s file_dest file_src\n",argv[0]);
        return 0;
    }
    for(size_t i=2;i<=argc;i++)
    {
        if(argv[i] != NULL)
        {
            int fd_src = open(argv[i],O_RDONLY);
            FOPEN_ERR(fd_src);
            lseek(fd_src,0,SEEK_SET);
            memset(buf,0,sizeof(buf));
            while((bytes = read(fd_src,buf,sizeof(buf)))>0)
            {
                write(fd_set,buf,bytes);
            }
        }
        close(fd_src);
    }

    return 0;
}